const { resolve } = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    entry: "./src/js/index.js",
    output: {
        filename: "js/index.js",
        path: resolve(__dirname, "dist"),
    },
    module: {
        rules: [
            {
                /**
                 * 设置检测规则:
                 *      package.json中eslintConfig中设置
                 *          "eslintConfig": {
                 *              "extends": "airbnb-base"
                 *          }
                 */
                test: /\.js$/,
                // 排除不需要检测的文件
                exclude: /node_modules/,
                loader: "eslint-loader",
                options: {
                    // 启动自动修复eslint的错误
                    fix: true,
                },
            },
        ],
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: "./src/index.html",
        }),
    ],
    mode: "development",
};
